//
//  ZHExampleViewController.swift
//  ZHPageView
//
//  Created by Rango on 2020/8/26.
//  Copyright © 2020 Rango. All rights reserved.
//

import UIKit

class ZHExampleViewController: UIViewController {

    var index: Int = 0 {
        didSet {
            print("ZHExampleViewController -- \(index)")
        }
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        //print("\(title!) \(#function)")

        view.backgroundColor = ZHConstant.randomColor
        
        let btn = UIButton(frame: CGRect(x: 0, y: 200, width: 100, height: 44))
        btn.setTitle("\(title!)", for: .normal)
        btn.backgroundColor = .lightGray
        btn.addTarget(self, action: #selector(btnAction), for: .touchUpInside)
        view.addSubview(btn)

        view.addSubview(customView)
    }
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()

        customView.frame = CGRect(x: 0, y: 250, width: 100, height: 44)
    }
    private lazy var customView: ZHIndicatorCustomView = {

        return $0
    }(ZHIndicatorCustomView())
    @objc private func btnAction() {
        let vc = ZHExampleTableController()
        vc.title = title
        navigationController?.pushViewController(vc, animated: true)
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print("\(title!) \(#function) \(index)")
    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        print("\(title!) \(#function) \(index)")
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        print("\(title!) \(#function) \(index)")
    }
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        print("\(title!) \(#function) \(index)")
    }
    deinit {
        //print("\(#file)-\(#line)-\(#function)--->销毁")
    }
}
